import java.util.Scanner;
import java.util.Arrays;
public class Dilatition{

    public static void main(String[] args){
    System.out.println("初始化一个长度为n的数组：");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int[] arr = new int[n];
        int[] arr1 = new int[n];

        //声明一个计数变量用来记录当前放入数组中的元素个数
        int count = 0;

        int num;
        String flag;
        outer: while (true) {

            for (int i = 0; i < arr.length; i++) {
                System.out.println("请输入放入的元素：");
                num = scanner.nextInt();
                arr[i] = num;
                count++;
                if (count >= arr.length*0.8){
                    arr1 = new int[arr.length+(arr.length>>1)];
                    System.arraycopy(arr,0,arr1,0,count);

                    arr = new int[arr.length+(arr.length>>1)];
                    System.arraycopy(arr1,0,arr,0,count);
                }
                System.out.println("是否继续输入？ y/n");
                flag = scanner.next();
                if (flag.equals("n")){
                    System.out.println("当前数组长度为"+arr.length+"当前数组元素为"+ Arrays.toString(arr));
                    break outer;
                }
            }
        }
	}
}